package com.nys.conci.base.validador;


import com.nys.conci.base.validador.anotacion.Cedula;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 *
 * @author Adam M. Gamboa González
 */
public class CedulaValidator implements ConstraintValidator<Cedula, String> {
    
    private final String regex = "\\d0(\\d){3,4}0\\d{3,4}";
    
    @Override
    public void initialize(Cedula constraintAnnotation) {
    }
    
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if(value == null || value.trim().equals("")){
            return false;
        }
        return value.matches(regex);
    }
}
